package langnstats.project.lib.crossvalidation;

import java.util.Arrays;

import langnstats.project.lib.WordType;

public class TrainTokens {
	public static int uniqueID = 1;
	
	private int id;
	
	private WordType[] trainTokens;
	public WordType[] getTokenArray(){ return this.trainTokens; }
	
	public int getID(){ return this.id; }
	
	private void generateID(){ this.id = uniqueID++; }
	
	public TrainTokens(WordType[] tokens){
		generateID();
		this.trainTokens = Arrays.copyOf(tokens, tokens.length);
	}
	
	public TrainTokens(WordType[] tokens, int notFrom, int notTo){
		generateID();
		
		int realTrainTokensLength = tokens.length-(notTo-notFrom);
		this.trainTokens = new WordType[realTrainTokensLength];
		for(int i=0; i<notFrom; i++){
			this.trainTokens[i] = tokens[i];
		}
		for(int i=notTo; i<tokens.length; i++){
			this.trainTokens[i-(notTo-notFrom)] = tokens[i];
		}
	}
	
	public boolean equals(Object o){
		if(!(o instanceof TrainTokens)){ return false; }
		TrainTokens cvtt = (TrainTokens)o;
		return this.getID()==cvtt.getID();
	}

}
